package A1_二叉树;

public class LC_700二叉搜索树中的搜素 {
    public static class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(){}
        TreeNode(int val){
            this.val=val;
        }
        TreeNode(int val,TreeNode left,TreeNode right){
            this.val=val;
            this.left=left;
            this.right=right;
        }
    }
    public TreeNode searchBST(TreeNode root, int val) {
        if(root==null || root.val==val)
            return root;
        TreeNode node=null;
        if(val<root.val)
            node=searchBST(root.left,val);
        if(val>root.val)
            node=searchBST(root.right,val);
        return node;
    }
}
